from tortoise.contrib.pydantic import pydantic_model_creator
from models import User
from pydantic import BaseModel


# 排除密码
User_Pydantic = pydantic_model_creator(User,
                                       name="User",
                                       exclude=["password"])

# 仅在创建用户时使用
UserIn_Pydantic = pydantic_model_creator(User,
                                         name="UserIn",
                                         exclude_readonly=True,
                                         exclude=["createTime","updateTime"])
UserIn_Pydantic_WITHOUT_P = pydantic_model_creator(User,
                                         name="UserIn_WITHOUT_P",
                                         exclude_readonly=True,
                                         exclude=["createTime","updateTime","password"])

# 修改密码传入请求模型
class UserIn_Modify_Password(BaseModel):
    # 原密码
    oldPassword: str
    # 新密码
    newPassword1: str
    # 确认新密码
    newPassword2: str